From 5d86b735d50a973bc158598d53e5855630e6e231 Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Fri, 21 Aug 2015 17:32:36 +0200 Subject: [PATCH] src/etc: Fix PEP8 issues in Python scripts --- src/etc/dl-snapshot.py | 2 +- src/etc/download.py | 11 +++++++---- src/etc/install-deps.py | 3 ++- src/etc/print-new-snapshot.py | 3 +-- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/etc/dl-snapshot.py b/src/etc/dl-snapshot.py index 23f9c5949..b279f536a 100644 --- a/src/etc/dl-snapshot.py +++ b/src/etc/dl-snapshot.py @@ -70,7 +70,7 @@ hash = snaps[date][platform] tarball = 'cargo-nightly-' + triple + '.tar.gz' url = 'https://static.rust-lang.org/cargo-dist/%s/%s' % \ - (date.strip(), tarball) + (date.strip(), tarball) dl_path = "target/dl/" + tarball dst = "target/snapshot" diff --git a/src/etc/download.py b/src/etc/download.py index 080fda9e2..807273782 100644 --- a/src/etc/download.py +++ b/src/etc/download.py @@ -5,15 +5,17 @@ import subprocess import sys import tarfile + def get(url, path, quiet=False): # see http://serverfault.com/questions/301128/how-to-download if sys.platform == 'win32': run(["PowerShell.exe", "/nologo", "-Command", "(New-Object System.Net.WebClient).DownloadFile('" + url + - "', '" + path + "')"], quiet=quiet) + "', '" + path + "')"], quiet=quiet) else: run(["curl", "-o", path, url], quiet=quiet) + def unpack(tarball, dst, quiet=False): if quiet: print("extracting " + tarball) @@ -31,6 +33,7 @@ def unpack(tarball, dst, quiet=False): shutil.move(tp, fp) shutil.rmtree(os.path.join(dst, fname)) + def run(args, quiet=False): if not quiet: print("running: " + ' '.join(args)) @@ -38,9 +41,9 @@ def run(args, quiet=False): # Use Popen here instead of call() as it apparently allows powershell on # Windows to not lock up waiting for input presumably. ret = subprocess.Popen(args, - stdin = subprocess.PIPE, - stdout = subprocess.PIPE, - stderr = subprocess.PIPE) + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) out, err = ret.communicate() code = ret.wait() if code != 0: diff --git a/src/etc/install-deps.py b/src/etc/install-deps.py index 0886bb249..1d73f69ca 100644 --- a/src/etc/install-deps.py +++ b/src/etc/install-deps.py @@ -37,6 +37,7 @@ else: rust_date = open('src/rustversion.txt').read().strip() url = 'https://static.rust-lang.org/dist/' + rust_date + def install_via_tarballs(): if os.path.isdir("rustc-install"): shutil.rmtree("rustc-install") @@ -46,7 +47,7 @@ def install_via_tarballs(): download.unpack(host_fname, "rustc-install", quiet=True) os.remove(host_fname) - if extra != None: + if extra is not None: extra_fname = 'rustc-nightly-' + extra + '.tar.gz' print("adding target libs for " + extra) download.get(url + '/' + extra_fname, extra_fname) diff --git a/src/etc/print-new-snapshot.py b/src/etc/print-new-snapshot.py index 7f0aff538..ecfbda033 100644 --- a/src/etc/print-new-snapshot.py +++ b/src/etc/print-new-snapshot.py @@ -1,6 +1,5 @@ # When updating snapshots, run this file and pipe it into `src/snapshots.txt` import os -import subprocess import sys import hashlib import download @@ -27,6 +26,6 @@ for platform in sorted(snaps): tarball = 'cargo-nightly-' + triple + '.tar.gz' url = 'https://static.rust-lang.org/cargo-dist/' + date + '/' + tarball dl_path = "target/dl/" + tarball - download.get(url, dl_path, quiet = True) + download.get(url, dl_path, quiet=True) h = hashlib.sha1(open(dl_path, 'rb').read()).hexdigest() print(' ' + platform + ' ' + h) -- 2.30.2